package com.shuzixiangcun.controller.front;

import com.shuzixiangcun.entity.Xiangcungaikuang;

import com.shuzixiangcun.service.front.XiangcungaikuangFServiceImpl;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 乡村概况表(Xiangcungaikuang)表控制层
 *
 * @author makejava
 * @since 2024-06-24 08:26:20
 */
@RestController
@RequestMapping("/xiangcungaikuang")
public class XiangcungaikuangFController {
    /**
     * 服务对象
     */
    @Resource
    private XiangcungaikuangFServiceImpl xiangcungaikuangService;



    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<Xiangcungaikuang> queryById(@PathVariable("id") Object id) {
        return ResponseEntity.ok(this.xiangcungaikuangService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param xiangcungaikuang 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<Xiangcungaikuang> add(Xiangcungaikuang xiangcungaikuang) {
        return ResponseEntity.ok(this.xiangcungaikuangService.insert(xiangcungaikuang));
    }

    /**
     * 编辑数据
     *
     * @param xiangcungaikuang 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<Xiangcungaikuang> edit(Xiangcungaikuang xiangcungaikuang) {
        return ResponseEntity.ok(this.xiangcungaikuangService.update(xiangcungaikuang));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Object id) {
        return ResponseEntity.ok(this.xiangcungaikuangService.deleteById(id));
    }

}

